package cn.edu.nit.sys.mapper;

import cn.edu.nit.sys.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @Author xiaobai
 * @Date 2022/9/4 12:58
 * @Version 1.0.0
 */
@Mapper
public interface IndexMapper extends BaseMapper<User> {

    @Select("select name from sys_position")
    List<String> getPosition();

    @Select("SELECT COUNT(1) AS total FROM sys_student")
    Integer studentTotal();

    @Select("SELECT COUNT(1) AS total FROM sys_teacher")
    Integer teacherTotal();

    @Select("SELECT COUNT(1) as total, GROUP_CONCAT(DISTINCT dept) as label from sys_student GROUP BY dept_id")
    List<Map<String, Integer>> studentCount();

    @Select("SELECT COUNT(1) AS total, grade FROM sys_student GROUP BY grade")
    List<Map<String, Integer>> gradeCount();

    @Update("update sys_test_data set card_id = #{idCard} where id = #{id}")
    int updateTestData(int id, String idCard);
}
